package com.zxt.content.copywriting.service.impl;

import com.zxt.enums.CommonStatusEnum;
import com.zxt.utils.ZXTBeanUtils;
import com.zxt.content.copywriting.manager.CopywritingTypeManager;
import com.zxt.content.copywriting.model.CopywritingType;
import com.zxt.content.copywriting.req.CopywritingTypeDTO;
import com.zxt.content.copywriting.resp.CopywritingTypeVO;
import com.zxt.content.copywriting.service.ICopywritingTypeService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文案类型模块业务逻辑层
 *
 * @author zxt
 */
@Service(value = "copywritingTypeServiceImpl")
@AllArgsConstructor
public class CopywritingTypeServiceImpl implements ICopywritingTypeService {

    private CopywritingTypeManager copywritingTypeManager;

    @Override
    public List<CopywritingTypeVO> queryList() {
        return ZXTBeanUtils.beanCopy(copywritingTypeManager.list(), CopywritingTypeVO.class);
    }

    @Override
    public void add(CopywritingTypeDTO dto) {
        //默认启用状态
        dto.setCommonStatus(CommonStatusEnum.ENABLE.getValue());
        copywritingTypeManager.save(ZXTBeanUtils.beanCopy(dto, CopywritingType.class));
    }

    @Override
    public void update(CopywritingTypeDTO dto) {
        copywritingTypeManager.updateById(ZXTBeanUtils.beanCopy(dto, CopywritingType.class));
    }
}
